from rest_framework.generics import ListAPIView,CreateAPIView
from rest_framework.generics import RetrieveAPIView,UpdateAPIView,DestroyAPIView
from apps.drf_test_0Django原始restful.models import BookinfoModels
from apps.drf_test_7_三级视图.serializer import BookThirdSserializer


class BookThirdGenericAPIView(ListAPIView,CreateAPIView):
    """
    三级视图-列表视图【通用get(),post()方法封装在父类】
    ListAPIView       继承mixins.ListModelMixin,GenericAPIView       get方法
    CreateAPIView     继承mixins.CreateModelMixin，GenericAPIView    post方法
    """
    queryset = BookinfoModels.objects.all()
    serializer_class = BookThirdSserializer


class BookDetailThirdGenericAPIView(RetrieveAPIView,UpdateAPIView,DestroyAPIView):
    """
    三级视图-详情视图【通用get(),put(),delete()方法封装在父类】
    RetrieveAPIView    继承mixins.RetrieveModelMixin,GenericAPIView   get方法
    UpdateAPIView      继承mixins.UpdateModelMixin，GenericAPIView    put方法
    DestroyAPIView     继承mixins.DestroyModelMixin，GenericAPIView   delete方法
    """
    queryset = BookinfoModels.objects.all()
    serializer_class = BookThirdSserializer